<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/include/head_common.html">
<title>用户<#if user.id??&&user.id!=''>修改<#else>添加</#if></title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#no").focus();
            $("#inputForm").validate({
                rules: {
                    loginName: {remote: "checkLoginName?oldLoginName=" + encodeURIComponent('${user.loginName!''}')}
                },
                messages: {
                    loginName: {remote: "用户登录名已存在"},
                    confirmNewPassword: {equalTo: "输入与上面相同的密码"}
                },
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
        function goback(){
        	$.cookie('goback','goback',{path: '/',expires: 1});
        	history.go(-1);
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="list">用户列表</a></li>
    <li class="active"><a href="edit?id=${user.id!''}">用户<#if user.id??&&user.id!=''>修改<#else>添加</#if></a></li>
</ul>
<br/>
<form id="inputForm"  action="edit" method="post" class="form-horizontal">
    <input type="hidden" name="id" value="${user.id!''}"/>
    <input type="hidden" name="photo" value="${user.photo!''}"/>
    <div class="control-group">
        <label class="control-label">归属公司:</label>
        <div class="controls">
            <@wolfking.treeView id="company" name="companyId" 
							value="${user.companyId!''}" 
							labelName="${company.name!''}"
                            labelValue="${company.name!''}"
                            title="公司" 
                            url="/office/treeData"
                            cssClass="required">
					<#include "/tool/treeTag.html">
			</@wolfking.treeView>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">归属部门:</label>
        <div class="controls">
            <@wolfking.treeView id="office" name="officeId" 
							value="${user.officeId!''}" 
							labelName="${office.name!''}"
                            labelValue="${office.name!''}"
                            title="部门" 
                            url="/office/treeData"
                            cssClass="required"
                            notAllowSelectParent="true">
					<#include "/tool/treeTag.html">
			</@wolfking.treeView>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">工号:</label>
        <div class="controls">
            <input type="text" id="no" name="no" value="${user.no!''}" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">姓名:</label>
        <div class="controls">
            <input type="text" name="name" value="${user.name!''}" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">登录名:</label>
        <div class="controls">
            <input id="oldLoginName" name="oldLoginName" type="hidden" value="${user.loginName!''}" />
            <input type="text" name="loginName" value="${user.loginName!''}" maxlength="50" class="required userName"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">密码:</label>
        <div class="controls">
            <input id="newPassword" name="newPassword" type="password" value="" maxlength="50" minlength="3"
                   class="<#if !user.id??||user.id==''>required</#if>"/>
            <#if !user.id??||user.id==''><span class="help-inline"><font color="red">*</font> </span></#if>
            <#if user.id??&&user.id!=''><span class="help-inline">若不修改密码，请留空。</span></#if>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">确认密码:</label>
        <div class="controls">
            <input id="confirmNewPassword" name="confirmNewPassword" type="password" value="" maxlength="50"
                   minlength="3" equalTo="#newPassword"/>
            <#if !user.id??||user.id==''><span class="help-inline"><font color="red">*</font></span></#if>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">邮箱:</label>
        <div class="controls">
            <input type="text" name="email" value="${user.email!''}" maxlength="100" class="email"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">电话:</label>
        <div class="controls">
            <input name="phone" type="text" value="${user.phone!''}" maxlength="100"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">手机:</label>
        <div class="controls">
            <input name="mobile" type="text" value="${user.mobile!''}" maxlength="100"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">是否允许登录:</label>
        <div class="controls">
            <select name="loginFlag" style="width:220px">
        		<option value="">请选择</option>
        		<#list loginDicts as dict>
        			<#if user.loginFlag??&&user.loginFlag==dict.value>
        				<option value="${dict.value!''}" selected="selected">${dict.label!''}</option>
            		<#else>
            			<option value="${dict.value!''}">${dict.label!''}</option>
            		</#if>
            	</#list>
        	</select>
            <span class="help-inline"><font color="red">*</font> “是”代表此账号允许登录，“否”则表示此账号不允许登录</span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">用户类型:</label>
        <div class="controls">
        	<select name="userType" style="width:220px">
        		<option value="">请选择</option>
        		<#list typeDicts as dict>
        			<#if user.userType??&&user.userType==dict.value>
        				<option value="${dict.value!''}" selected="selected">${dict.label!''}</option>
            		<#else>
            			<option value="${dict.value!''}">${dict.label!''}</option>
            		</#if>
            	</#list>
        	</select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">备注:</label>
        <div class="controls">
            <textarea name="remarks">${user.remarks!''}</textarea>
        </div>
    </div>
    <#if user.id??&&user.id!=''>
        <div class="control-group">
            <label class="control-label">创建时间:</label>
            <div class="controls">
                <label class="lbl">${user.createDate?string("yyyy-MM-dd HH:mm:ss")}</label>
            </div>
        </div>
        <div class="control-group">
        	<label class="control-label">上次登录:</label>
        	<div class="controls">
            	<label class="lbl">
            	IP: ${user.loginIp!''}&nbsp;&nbsp;&nbsp;&nbsp;
            	<#if user.loginDate??>
            		时间：${user.loginDate?string("yyyy-MM-dd HH:mm:ss")}
            	<#else>
            		用户尚未登录过
            	</#if>
            	</label>
        	</div>
    	</div>
    </#if>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="goback()"/>
    </div>
</form>
</body>
</html>